<?php
/**
 * Created by PhpStorm.
 * User: yangt
 * Date: 2019/8/27
 * Time: 15:40
 */

namespace app\mall\controller\my;

use app\mall\controller\User;

class MyEntry extends User {

    protected function assignOneGoods($id = 0)
    {

        $info = model('mall/MallGoods')->where(['status'=>1])->find($id);
        if(empty($info)) {
            $this->error('您收藏的商品已下架！');
        }
        if(\yunbao\modelhelp::installed('Vip') && ! empty($info['type_id'])) {
            $vip_info = model('vip/Vip')->find($info['type_id']);

            $info['vip_title'] = $vip_info['title'];
        }

        $this->assign('info', $info);
    }

    protected function assignGoods()
    {
        $map = ['status' => 1];
        $list = model('MallGoods')->where($map)->order('num_stock desc,id desc')->limit(12)->select();
        $this->assign('goods_list', $list);
    }

    protected function assignGoodsOrder($goods_id = 0)
    {
        $map  = ['goods_id' => $goods_id, 'status' => 1];
        $list = model('mall/MallOrder')->where($map)->select();
        if( ! empty($list)) {
            foreach($list as &$item) {
                $user_info    = \yunbao\user::query_user(['nickname', 'id'], $item['user_id']);
                $item['user'] = $user_info;
            }
        }
        $this->assign('goods_order_list', $list);
    }

}